{% load static %}
<!DOCTYPE html>
<html lang="en">


<head>
    <meta charset="UTF-8">
    <title>注入</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href={% static "css/font.css" %}>
    <link rel="stylesheet" href={% static "css/xadmin.css" %}>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src={% static "lib/layui/layui.js" %} charset="utf-8"></script>


</head>

<body>


<form class="layui-form layui-form-pane">
    <div class="layui-form-item">
        <label class="layui-form-label">域名</label>
        <div class="layui-input-inline">
            <input type="text" name="domain" placeholder="不填默认全部数据包" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">注入类型</label>
        <div class="layui-input-block">
            <select name="type" lay-filter="type">
                <option value="" selected=""></option>
                <option value="start">跳过已经注入过的数据包</option>
                <option value="restart">重新注入</option>
            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <button class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
    </div>

</form>


<script>
    layui.use(['form'], function () {
        var form = layui.form;

        //监听提交
        form.on('submit(submit)', function (data) {

		
            $.ajax({
                url: "{% url "start_sqlmap" %}",
                type: 'post',
                data: {
                    domain:data.field.domain,
                    type:data.field.type
                },

                success: function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 5});//失败的表情
                        return;
                    } else if (data.code == 200) {
                        layer.msg(data.msg, {
                            icon: 6,//成功的表情
                            time: 4000 //1秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            //
							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
							parent.layer.close(index); //再执行关闭   
							location.reload();
                        });
                    }
                },
                complete: function () {
                    layer.close(this.layerIndex);
                },
            });


            return false;
        });


    });
</script>


</body>
</html>